<template>
  <div class="warehouseInformation-page">
    <div class="table-container">
      <BasicInformation
        :orderDetails="list.data"
        :listData="listData"
        @buttons="getButtonsParams"
      />
    </div>
    <div class="table-container">
      <Authorization :orderDetails="list.data" @buttons="getButtonsParams" />
    </div>
    <div class="table-container">
      <Device :orderDetails="list.data" />
    </div>
  </div>
</template>

<script setup>
import { ref, reactive } from "vue";
import BasicInformation from "./basicInformation.vue";
import Authorization from "./authorization.vue";
import Device from "./device.vue";
import { getDictionary } from "@/service/modules/publicModule";
import { getCparkForm, getCparkCom } from "../request.js";
import { useRoute } from "vue-router";
const route = useRoute();

const getButtonsParams = (val) => {
  console.log(val);
  if (val === "submit") {
    getData();
    init();
  }
};

const list = reactive({
  data: {},
});

const getData = async () => {
  await getCparkForm(route.query.id).then((res) => {
    console.log(res);
    if (res.data.code === 0) {
      list.data = res.data.result;
    }
  });
};

const listData = reactive({
  comNameList: [],
  statusList: [],
  categoryList: [],
  typeList: [],
});

const init = async () => {
  // 运营状态
  await getDictionary("cpark_operational_status").then((res) => {
    listData.statusList = res.data.result;
  });
  // 物业名称
  await getCparkCom().then((res) => {
    listData.comNameList = res.data.result;
  });
  // 车场类别
  await getDictionary("cpark_category").then((res) => {
    listData.categoryList = res.data.result;
  });
  // 建筑类别
  await getDictionary("cpark_type").then((res) => {
    listData.typeList = res.data.result;
  });
};

getData();
init();
</script>
<style lang="less">
body {
  background-color: var(--main-bg-color);
}
</style>
<style lang="less" scoped>
.warehouseInformation-page {
  // padding: 24px;
  background: var(--main-bg-color);
}
.table-container {
  margin: 24px 170px;
  min-height: 100%;
  min-width: 1100px;
  padding: 24px;
  background: #fff;
  border-radius: 6px;
}
</style>
